<template>
	<view class="scrollCom">
		<scroll-view scroll-y :style="{height: `${scrollViewHeight}px`, position: 'fixed',top: 0,left: 0,right: 0,'z-index': 8,
		}" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
			<slot></slot>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollViewHeight: 0,
			}
		},
		mounted() {
			this.scrollViewHeight_init()
		},
		methods: {
			scrollViewHeight_init() {
				const windowHeight = uni.getSystemInfoSync().windowHeight
				if (windowHeight) {
					// 68 底部tabBar
					const scrollViewHeight = windowHeight - 68
					this.$set(this, 'scrollViewHeight', scrollViewHeight)
				}
			},
			upper: function(e) {
				// console.log(e)
			},
			lower: function(e) {
				// console.log(e)
			},
			scroll: function(e) {
				// console.log(e.detail.scrollTop)
				const scrollTop = e.detail.scrollTop
				const gradientScale = scrollTop / 220
				// console.log(gradientScale);
				// this.gradientScale = gradientScale
				this.$emit("setGradientScale", gradientScale)
			},
		},
	}
</script>

<style lang="scss" scoped>
	.scrollCom {}
</style>